<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
<title>Felicalib Sample Applet JNLP Test</title>
<script type="text/javascript">
var applet = null;
var errflg = false;
    function appletReader(loadLimit) {
        try {
            applet = document.felicaHeadlessApplet;
            applet.getAppletName();
            errflg = false;
        } catch(err) {
            errflg = true;
        }
        if (errflg) {
            if (loadLimit <= 0) return;
                loadLimit--;
                window.setTimeout(appletReader, 1000, loadLimit);
        } else {
        }
    }

    appletReader(15);

    function getIDM(){
        appletReader(1);
        var idm = applet.getIDm();
        alert(idm);
    }
    function getPMM(){
        appletReader(1);
        var pmm = applet.getPMm();
        alert(pmm);
    }
    function getData(){
        var aServiceCode = document.getElementById("serviceCode").value;
        var anAddr = document.getElementById("addr").value;
        if (aServiceCode != "" && anAddr != "") {
            appletReader(1);
            var data = applet.getData(aServiceCode, anAddr);
            document.getElementById("data").value = data;
        }
    }
    function setCard(){
        var aServiceCode = document.getElementById("serviceCode").value;
        var anAddr = document.getElementById("addr").value;
        var aData = document.getElementById("data").value;
        if (aServiceCode != "" && anAddr != "") {
            appletReader(1);
            applet.setCard(aServiceCode, anAddr, aData);
        }
    }
</script>
</head>
<body>
    <button onclick='getIDM();'>get IDM</button>
    <button onclick='getPMM();'>get PMM</button><br/>
    serviceCode:<input type="text" id="serviceCode" name="serviceCode" size="10" /><br/>
    addr:<input type="text" id="addr" name="addr" size="5" /><br/>
    data:<input type="text" id="data" name="data" size="100" /><br/>
    <button onclick='getData();'>get Data</button>
    <button onclick='setCard();'>set Card</button>
    <applet alt="Headless Applet" name="felicaHeadlessApplet"
        code="com.googlecode.felicalib.sample.applet.FelicaHeadlessApplet"
        width="1" height="1" >
        <param name="draggable" value="true">
        <param name="jnlp_href" value="FelicalibSampleApplet.jnlp">
    </applet>
</body>
</html>